package com.example.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.example.pojo.operateGuideBookPojo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;
import java.util.List;

/**
 * ClassName:operateGuideBookMapp
 * Description:
 *
 * @Author 赵永峰
 * @Create 2024/7/19 23:17
 * @Version 1.0
 */
@Mapper
public interface operateGuideBookMapp {
    //插入一行全新的数据
    @DS("baodingRussia")
    @Insert("insert into operate_Book (workshop, lineName, op, " +
            "fileName, editionNum, writeDate, " +
            "executeDate, fileNum, writeUse, " +
            "examineUse, ratifyUse, countersignUse, " +
            "workBook, productId, partList, " +
            "editRecord, controlSign, threeBookSign, " +
            "partsList, bookType, deleteSign, operator, " +
            "establishTime, updateTime, deviceTime,caseUse)" +
            " VALUES (#{workshop},#{lineName},#{op}," +
            "#{fileName},#{editionNum},#{writeDate}," +
            "#{executeDate},#{fileNum},#{writeUse}," +
            "#{examineUse},#{ratifyUse},#{countersignUse}," +
            "#{workBook},#{productId},#{partList}," +
            "#{editRecord},#{controlSign},#{threeBookSign}," +
            "#{partsList},#{bookType},#{deleteSign},#{operator}," +
            "#{establishTime},#{updateTime},#{deviceTime},#{caseUse})")
    void interOne(operateGuideBookPojo operateGuideBook);
    @DS("baodingRussia")
    @Select("select * from operate_Book where ${filedName}=#{filedVal} and deleteSign=1")
    List<operateGuideBookPojo> inquiryByOneField(String filedName, String filedVal);
    @DS("baodingRussia")
    //编辑一行数据，是表头数据
    @Update("update operate_Book set " +
            "workshop=#{workshop}," +
            "lineName=#{lineName}," +
            "op=#{op}," +
            "editionNum=#{editionNum}," +
            "fileName=#{fileName}," +
            "writeDate=#{writeDate}," +
            "executeDate=#{executeDate}," +
            "writeUse=#{writeUse}," +
            "examineUse=#{examineUse}," +
            "ratifyUse=#{ratifyUse}," +
            "countersignUse=#{countersignUse} " +
            "where id=#{id}")
    void editChangeModelTable(operateGuideBookPojo operateGuideBook);
    //删除一行数据，删除的事表头数据,修改的是int形式的数据
    @DS("baodingRussia")
    @Update("update operate_Book set ${fieldName}=#{fieldVal} where id=#{id}")
    void editFielDInt(Integer id, String fieldName, int fieldVal);
    //修改一个字符串类型的字段，现在用在修改作业指导书上，同时也传来了旧的内容，作为修改修改记录用,同时修改了编制时间
    @DS("baodingRussia")
    @Update("update operate_Book set ${fieldName}=#{fieldVal},editRecord=#{editRecord},updateTime=#{update} where id=#{id}")
    void editChangeModelField(Integer id, String fieldName, String fieldVal, String editRecord, LocalDateTime update);
    //修改一个字段，是字符串的字段,和一个修改时间，现在用在了修改作业指导书的内容里面。
    @DS("baodingRussia")
    @Update("update operate_Book set ${fieldName}=#{fieldVal},updateTime=#{dateTime} where id=#{id}")
    void editFieldOneById(Integer id, String fieldName, String fieldVal, LocalDateTime dateTime);
    @DS("baodingRussia")
    @Select("select * from operate_Book where ${firstFiledName}=#{firstFiledVal} and ${secondFiledName}=#{secondFiledVal} and ${thirdFiledName}=#{thirdFiledVal} and deleteSign=1")
    List<operateGuideBookPojo> inquiryByThreeField(String firstFiledName, String secondFiledName, String thirdFiledName, String firstFiledVal, String secondFiledVal, String thirdFiledVal);
    //根据一个id，编辑一个字段，不需要写整行的编辑时间
    @DS("baodingRussia")
    @Update("update operate_Book set ${filedName}=#{filedVal} where id=#{id}")
    void editOneFiledById(Integer id, String filedName, String filedVal);
    //去查询所有的数据
    @DS("baodingRussia")
    @Select("select * from operate_Book where deleteSign=1")
    List<operateGuideBookPojo> inquiryGuideBookAll();
}
